<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
</head>
<body>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	<form class="form-horizontal" onsubmit="return false" id="form">
		<fieldset>
			<input type="hidden" id="id" name="id">
			<div class='form-group'>
				<label class='col-md-2 control-label'>categoryId</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='categoryId' type='text' name='categoryId' id='categoryId' data-bv-notempty='true' data-bv-notempty-message='categoryId 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>parentId</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='parentId' type='text' name='parentId' id='parentId' data-bv-notempty='true' data-bv-notempty-message='parentId 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>categoryName</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='categoryName' type='text' name='categoryName' id='categoryName' data-bv-notempty='true' data-bv-notempty-message='categoryName 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>image</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='image' type='text' name='image' id='image' data-bv-notempty='true' data-bv-notempty-message='image 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>state</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='state' type='text' name='state' id='state' data-bv-notempty='true' data-bv-notempty-message='state 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>simpleDescribe</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='simpleDescribe' type='text' name='simpleDescribe' id='simpleDescribe' data-bv-notempty='true' data-bv-notempty-message='simpleDescribe 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>recommend</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='recommend' type='text' name='recommend' id='recommend' data-bv-notempty='true' data-bv-notempty-message='recommend 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>createTime</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='createTime' type='text' name='createTime' id='createTime' data-bv-notempty='true' data-bv-notempty-message='createTime 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>updateTime</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='updateTime' type='text' name='updateTime' id='updateTime' data-bv-notempty='true' data-bv-notempty-message='updateTime 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>adminId</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='adminId' type='text' name='adminId' id='adminId' data-bv-notempty='true' data-bv-notempty-message='adminId 不能为空'>
				</div>
			</div>



			<div class="form-actions">
				<div class="row" align="center">
					<div class="col-md-12">
					    <button class="btn btn-primary" onclick="location.href='tGoodsCategoryList.html'">返回</button>
						<button class="btn btn-primary" type="submit" onclick="update()">
							<i class="fa fa-save"></i> 保存
						</button>
					</div>
				</div>
			</div>

		</fieldset>
	</form>
</div>
	<script type="text/javascript" src="../../js/libs/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="../../js/jq.js"></script>
	<script type="text/javascript" src="../../js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
	<script type="text/javascript" src="../../js/common.js"></script>
	<script type="text/javascript" src="../../layui/layui.js"></script>
	<script type="text/javascript">
		layui.use(['layer','laydate'], function(){
		    var layer = layui.layer;
		});
		
		initData();
		
		function initData(){
			var id = getUrlParam("id");
			if(id != ""){
				$.ajax({
					type : 'get',
					url : '/tGoodsCategorys/'+id,
					async : false,
					success : function(data) {
						$('#categoryId').val(data.categoryId);
						$('#parentId').val(data.parentId);
						$('#categoryName').val(data.categoryName);
						$('#image').val(data.image);
						$('#state').val(data.state);
						$('#simpleDescribe').val(data.simpleDescribe);
						$('#recommend').val(data.recommend);
						$('#createTime').val(data.createTime);
						$('#updateTime').val(data.updateTime);
						$('#adminId').val(data.adminId);

					}
				});
			}
		}

		function update() {
			$('#form').bootstrapValidator();
			var bootstrapValidator = $("#form").data('bootstrapValidator');
			bootstrapValidator.validate();
		    if(!bootstrapValidator.isValid()){
			   return;
		    }
		    
		    var formdata = $("#form").serializeObject();

			$.ajax({
				type : 'put',
				url : '/tGoodsCategorys',
				contentType: "application/json; charset=utf-8",  
				data : JSON.stringify(formdata),
				success : function(data) {
					layer.msg("修改成功", {shift: -1, time: 1000}, function(){
                        location.href = "tGoodsCategoryList.html";
                    });
				}
			});
		}
		
	</script>
</body>
</html>
